<input type="hidden" value="<?php echo $this->number;?>" name="number_box" id="number_box" >
<input type="hidden" value="<?php echo $this->number;?>" name="count" id="count" >
<input type="hidden" value="" name="num_img" id="num_img" >
<?php if(count($this->arrValue)>0):?>
<?php $i = -1; for($num=0;$num<$this->number;$num++):?>
    <?php
        $i++;
        $classCss = ($i%2 == 0)?"alpha":"omega";

        $value = $this->arrValue[$i];
        $valueContent = isset($this->arrValueContent[$value->value_type_id])?$this->arrValueContent[$value->value_type_id]:null;
    ?>
    <div class="grid_5 t_a_bottom <?php echo $classCss;?>">
        <div class="div_tabs">
            <ul class="t_a_ui_helper_head">
                <li><a href="#tab1<?php echo $num+1;?>"><span><?php echo $this->translator('value_general');?></span></a></li>
                <?php foreach($this->languages as $language):?>
                <li><a href="#tab2<?php echo $num+1;?>_<?php echo $language->language_code;?>"><span><?php echo $language->language_name;?></span></a></li>
                <?php endforeach;?>
                <li><a href="#tab3<?php echo $num+1;?>"><span><?php echo $this->translator('value_image');?></span></a></li>
                <?php if($this->allow('delete-value')):?>
                <li style="margin: 5px 0pt 0pt 15px;" rel="<?php echo $value->value_type_id;?>">
                    <span style="color:#fff"><input type="checkbox" name="cb_del_value_<?php echo $value->value_type_id;?>" id="cb_del_value_<?php echo $value->value_type_id;?>"></span>
                    <span style="color:#fff">&nbsp;<?php echo $this->translator('value_type_delete')?></span>
                </li>
                <?php endif;?>
            </ul>
            <div id="tab1<?php echo $num+1;?>">
                <div class="clearfix">
                    <div class="clearfix t_a_bottom">
                        <div class="grid_5 alpha">
                            <label><?php echo $this->translator('value_type_name');?>:</label>
                            <input type="hidden" value="<?php echo $value->value_type_id;?>" id="value_type_id_<?php echo $num+1;?>" name="value_type_id_<?php echo $num+1;?>">
                            <input type="text" value="<?php echo $value->value_type_name;?>" id="value_type_name_<?php echo $num+1;?>" name="value_type_name_<?php echo $num+1;?>" style="width: 220px;">
                        </div>
                    </div>
                    <div class="clearfix t_a_bottom">
                        <div class="grid_5 alpha">
                            <label><?php echo $this->translator('value_type_costs');?>:</label>
                            <input type="text" value="<?php echo $value->value_type_costs;?>" id="value_type_costs_<?php echo $num+1;?>" name="value_type_costs_<?php echo $num+1;?>" style="width: 80px;">
                        </div>
                    </div>
                    <div class="clearfix t_a_bottom">
                        <div class="grid_5 alpha">
                            <label><?php echo $this->translator('value_type_price');?>:</label>
                            <input type="text" value="<?php echo $value->value_type_price;?>" id="value_type_price_<?php echo $num+1;?>" name="value_type_price_<?php echo $num+1;?>" style="width: 80px;">
                        </div>
                    </div>
                </div>
            </div>
            <?php foreach($this->languages as $language):?>
            <?php
                $languageContent = isset($valueContent[$language->language_code])?$valueContent[$language->language_code]:null;
            ?>
            <div id="tab2<?php echo $num+1;?>_<?php echo $language->language_code;?>">
                <input type="hidden" value="<?php echo $language->language_code;?>" name="language_code_<?php echo $num+1;?>_<?php echo $language->language_code;?>"  name="language_code_<?php echo $num+1;?>_<?php echo $language->language_code;?>">
                <input type="hidden" value="<?php echo ($languageContent)?$languageContent->value_content_id:null;?>" name="value_content_id_<?php echo $num+1;?>_<?php echo $language->language_code;?>"  name="value_content_id_<?php echo $num+1;?>_<?php echo $language->language_code;?>">
                <div class="clearfix">
                    <div class="clearfix t_a_bottom">
                        <div class="grid_5 alpha">
                            <label><?php echo $this->translator('value_content_name');?> <?php echo $language->language_name;?>:</label>
                            <input type="text" value="<?php echo ($languageContent)?$languageContent->value_content_name:null;?>" id="value_content_name_<?php echo $num+1;?>_<?php echo $language->language_code;?>" name="value_content_name_<?php echo $num+1;?>_<?php echo $language->language_code;?>" style="width: 220px;">
                        </div>
                    </div>
                    <div class="clearfix t_a_bottom">
                        <div class="grid_5 alpha">
                            <label><?php echo $this->translator('value_content_description');?>:</label>
                            <textarea id="value_content_description_<?php echo $num+1;?>_<?php echo $language->language_code;?>" name="value_content_description_<?php echo $num+1;?>_<?php echo $language->language_code;?>" style="width:220px; height:55px;"><?php echo ($languageContent)?$languageContent->value_content_description:null;?></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <?php endforeach;?>
            <div id="tab3<?php echo $num+1;?>">
                <div class="clearfix">
                    <div class="clearfix t_a_bottom">
                        <div class="grid_5 alpha">
                            <div class="grid_3 alpha" style="width:180px">
                                <div>
                                    <a href="javascript:void(0)" class="browser_img" id="<?php echo $num+1?>"><?php echo $this->translator('value_image_browse')?></a>&nbsp;&nbsp;
                                    <a href="javascript:void(0)" class="add_link" rel="<?php echo $num+1?>"><?php echo $this->translator('value_add_link')?></a>&nbsp;&nbsp;
                                    <a href="javascript:void(0)" class="del_img" rel="<?php echo $num+1?>"><?php echo $this->translator('value_image_del')?></a>
                                </div>
                                <div>
                                    <textarea onChange="changeImage(this.value,'<?php echo $num+1;?>');" readonly="readonly" id="value_type_icon_<?php echo $num+1;?>" name="value_type_icon_<?php echo $num+1;?>" style="width:190px; height:70px;"><?php echo trim($value->value_type_icon);?></textarea>
                                </div>
                            </div>
                            <div class="grid_2 omega"  style="width:180px">
                                <div id="viewIMG_<?php echo $num+1;?>" name="viewIMG_<?php echo $num+1;?>" style="width:165px; overflow:hidden;">
                                    <?php if($value->value_type_icon):?>
                                        <img height="95px" src="<?php echo $value->value_type_icon;?>">
                                    <?php endif;?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php if($i%2==1):?><div class="clearfix"></div><?php endif;?>
<?php endfor;?>
<?php else:?>
    <div id="no_value"><?php echo $this->translator('not_found_any_value')?></div>
<?php endif;?>

<script type="text/javascript">

function insertImage(url) {
    id = $('#num_img').val();
    document.getElementById('viewIMG_'+id).innerHTML = '<img height="95px" src="'+url+'" />';
    document.getElementById('value_type_icon_'+id).value = url;
};

function changeImage(url, id){
    document.getElementById('viewIMG_'+id).innerHTML = '<img height="95px" src="'+url+'" />';
    document.getElementById('value_type_icon_'+id).value = url;
};

$(document).ready(function() {

    $(".div_tabs").tabs();

    /**
    * Script handle for tab image
    */
    $('.browser_img').click(function(){
        num = $(this).attr('id');
        $('#num_img').attr('value', num);
        $("#libLoaderContainer_1").dialog('open');
    });

    /**
    * Script handle for tab image
    */
    $('.del_img').click(function(){
        num = $(this).attr('rel');

        $('#value_type_icon_'+num).attr('value', '');
        $('#viewIMG_'+num).html('');
    });

    /**
    * Script handle for tab image
    */
    $('.add_link').click(function(){
        num = $(this).attr('rel');
        $('#value_type_icon_'+num).removeAttr('readonly');
    });

});
</script>